//
//  LHSightViewController.m
//  Knight_Tour
//
//  Created by Bruce_Lin on 15/5/13.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHSightViewController.h"
#import "LHSightView.h"
#import "MyNavgationView.h"
#import "LHNetworkHandleWithPost.h"
#import "LHSightModel.h"

@interface LHSightViewController ()
@property (nonatomic ,retain)NSArray *urlArr;
@property (nonatomic ,retain)NSMutableArray *sightModelArr;
@end

@implementation LHSightViewController

- (void)dealloc
{
    [_urlArr release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBarController.tabBar.hidden = YES;
    
    self.sightModelArr = [NSMutableArray array];
    self.urlArr = @[@"&a_t=1431161862000&token=554dbf3478d18&mtid=10&startpos=0&eachpage=5&issue=2&sign=d3d2a50949374350a955e05f68b66579f86b8fea",
                        @"&a_t=1431161906000&token=554dbf3478d18&mtid=5&startpos=0&eachpage=5&issue=0&sign=cbe1355a2323e002d47d91929f67e154f96a032c",
                        @"&a_t=1431162060000&token=554dbf3478d18&mtid=17&startpos=0&eachpage=5&issue=0&sign=b751b7398a4b446a8d4d7d5c1e334955e46e72fc",
                        @"&a_t=1431162142000&token=554dbf3478d18&mtid=13&startpos=0&eachpage=5&issue=0&sign=6edfa7e552501372b6951be1777b2dd2d66e2d60",
                        @"&a_t=1431162255000&token=554dbf3478d18&mtid=23&startpos=0&eachpage=5&issue=1&sign=8910f4a8300716450f86f90acf125239fbe46d67",
                        @"&a_t=1431306791000&token=554dbf3478d18&mtid=14&startpos=0&eachpage=5&issue=4&sign=e2c1fbf5b19b27917b8289f53f24ec5bdc734cd5",
                        @"&a_t=1431162060000&token=554dbf3478d18&mtid=17&startpos=0&eachpage=5&issue=0&sign=b751b7398a4b446a8d4d7d5c1e334955e46e72fc",
                        @"&a_t=1431162429000&token=554dbf3478d18&mtid=11&startpos=0&eachpage=5&issue=0&sign=e1cae8f0bc3022df5cad100ed2145a897030c84e",
                        @"&a_t=1431162524000&token=554dbf3478d18&mtid=25&startpos=0&eachpage=5&issue=1&sign=5d7fbd61290f9e844deeb4ccd011312293da6b26"];
    [self getData];
    [self creatNavigation];
}

- (void)getData
{
    [LHNetworkHandleWithPost getDataWithURL:@"http://www.roadqu.com/api/mobile/qunawan/tour/seasonfunplacelist" Body:self.urlArr[_clickIndexPath.row] completion:^(id result) {
        
        for (NSDictionary *tempdic in [result objectForKey:@"data"]) {
            
            LHSightModel *model = [[LHSightModel alloc]initWithDic:tempdic];
            [self.sightModelArr addObject:model];
            [model release];
        }
        //数据获取完之后创建视图
        [self createTableView];
    }];
    
}

- (void)createTableView
{
    LHSightView *sightDetail = [[LHSightView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    sightDetail.sightModelArr = self.sightModelArr;
    [self.view addSubview:sightDetail];
    [sightDetail release];
}

- (void)creatNavigation
{
    MyNavgationView *navi = [[MyNavgationView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    navi.leftAction = @selector(back);
    navi.leftTarget = self;
    [navi creatLeftButtonWithImage:@"btn_nav_back"];
    [self.view addSubview:navi];
    [navi release];
}

- (void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
